//
//  HMHomeTitleButton.swift
//  iOSWeibo11
//
//  Created by Apple on 16/7/22.
//  Copyright © 2016年 Apple. All rights reserved.
//

import UIKit

class HMHomeTitleButton: UIButton {
    
    convenience init(title: String) {
        self.init(frame: CGRectZero)
        
        self.setTitle(title, forState: UIControlState.Normal)
        self.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        self.setImage(UIImage(named: "navigationbar_arrow_down"), forState: UIControlState.Normal)
        self.sizeToFit()
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        
        // 改变图片的位置
        // 1.将文字移动最左边
        self.titleLabel?.frame.origin.x = 0
        
        // 2.将图片的x值在文字的右边
        self.imageView?.frame.origin.x = self.titleLabel!.frame.width + 4
    }

}
